package com.taoyibao.hongcanting.ui.restaurant.area;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;

import com.taoyibao.hongcanting.R;
import com.taoyibao.hongcanting.base.BaseRelativeLayout;
import com.taoyibao.hongcanting.ui.mine.activity.RechargeActivity;

/**
 * @author TangAnna
 * @description: 舞台弹窗中底部发送模块
 * @date :${DATA} 13:34
 */
public class GiftSendArea extends BaseRelativeLayout<String> implements View.OnClickListener {
    /**
     * 账户余额
     */
    private TextView mTvBalance;


    public GiftSendArea(Context context) {
        super(context);
    }

    public GiftSendArea(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public GiftSendArea(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void initView(Context context, AttributeSet attrs, int defStyleAttr) {
        mTvBalance = findViewById(R.id.tv_dialogGift_balance);
        findViewById(R.id.tv_dialogGift_recharge).setOnClickListener(this);
        findViewById(R.id.iv_dialogGift_sned).setOnClickListener(this);
    }

    @Override
    public void setData(String data) {
        if (!TextUtils.isEmpty(data)) {
            mTvBalance.setText(data);
        }
    }

    @Override
    protected int bindLayout() {
        return R.layout.area_gift_send;
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.iv_dialogGift_sned://发送
                if (mGiftSendListener != null) {
                    mGiftSendListener.onSend();
                }
                break;
            case R.id.tv_dialogGift_recharge://充值
                getContext().startActivity(new Intent(getContext(), RechargeActivity.class));
                break;
        }
    }

    private GiftSendListener mGiftSendListener;

    /**
     * 设置发送事件
     *
     * @param giftSendListener
     */
    public void setGiftSendListener(GiftSendListener giftSendListener) {
        mGiftSendListener = giftSendListener;
    }

    public interface GiftSendListener {
        void onSend();
    }
}
